package org.tp8.sampleapp.jaxb.adapter;

import java.util.UUID;

import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 * The Class XmlLongAdapter.
 */
public class XmlUUIDAdapter extends XmlAdapter<String, UUID> {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object)
	 */
	@Override
	public String marshal(UUID id) throws Exception {
		String result;
		if (id == null) {
			result = "";
		} else {
			result = id.toString();
		}
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
	 */
	@Override
	public UUID unmarshal(String id) throws Exception {
		return UUID.fromString(id);
	}
}